﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.graph.utils {
    import flash.utils.*;

    public class PostRequest {

        public var boundary:String;// = "-----"
        protected var postData:ByteArray;

        public function PostRequest(){
            createPostData();
        }
        public function getPostData():ByteArray{
            postData.position = 0;
            return (postData);
        }
        protected function writeDoubleDash():void{
            postData.writeShort(0x2D2D);
        }
        public function writeFileData(_arg1:String, _arg2:ByteArray, _arg3:String):void{
            var _local4:String;
            var _local5:int;
            var _local6:uint;
            writeBoundary();
            writeLineBreak();
            _local4 = "Content-Disposition: form-data; filename=\"";
            _local5 = _local4.length;
            _local6 = 0;
            while (_local6 < _local5) {
                postData.writeByte(_local4.charCodeAt(_local6));
                _local6++;
            };
            postData.writeUTFBytes(_arg1);
            writeQuotationMark();
            writeLineBreak();
            _local4 = _arg3;
            _local5 = _local4.length;
            _local6 = 0;
            while (_local6 < _local5) {
                postData.writeByte(_local4.charCodeAt(_local6));
                _local6++;
            };
            writeLineBreak();
            writeLineBreak();
            _arg2.position = 0;
            postData.writeBytes(_arg2, 0, _arg2.length);
            writeLineBreak();
        }
        public function createPostData():void{
            postData = new ByteArray();
            postData.endian = Endian.BIG_ENDIAN;
        }
        public function writePostData(_arg1:String, _arg2:String):void{
            var _local3:String;
            writeBoundary();
            writeLineBreak();
            _local3 = (("Content-Disposition: form-data; name=\"" + _arg1) + "\"");
            var _local4:uint = _local3.length;
            var _local5:Number = 0;
            while (_local5 < _local4) {
                postData.writeByte(_local3.charCodeAt(_local5));
                _local5++;
            };
            writeLineBreak();
            writeLineBreak();
            postData.writeUTFBytes(_arg2);
            writeLineBreak();
        }
        protected function writeLineBreak():void{
            postData.writeShort(3338);
        }
        protected function writeBoundary():void{
            writeDoubleDash();
            var _local1:uint = boundary.length;
            var _local2:uint;
            while (_local2 < _local1) {
                postData.writeByte(boundary.charCodeAt(_local2));
                _local2++;
            };
        }
        public function close():void{
            writeBoundary();
            writeDoubleDash();
        }
        protected function writeQuotationMark():void{
            postData.writeByte(34);
        }

    }
}//package com.facebook.graph.utils 
